package samples.chapter05;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/chapter05")
@RestController()
public class Chapter05BookJpaController {
    @Autowired
    Chapter05BookJpaService bookJpaService;

    @GetMapping("/finnAll")
    public void finAll() {
        PageRequest pageable = PageRequest.of(2, 3);
        Page<Chapter05Book> page = bookJpaService.getBookByPage(pageable);
        System.out.println("总页数:" + page.getTotalPages());
        System.out.println("总记录数：:" + page.getTotalElements());
        System.out.println("查询结果:" + page.getContent());
        System.out.println("当前页数：:" + page.getNumber());
        System.out.println("当前页记录数：:" + page.getNumberOfElements());
        System.out.println("每页记录数：:" + page.getSize());
    }
}
